package com.mz.ozy.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mz.ozy.R;
import com.mz.ozy.bean.MyOrderBean;
import com.mz.ozy.bean.MyOrderInfoBean;
import com.mz.ozy.utils.glideUtils.GlideUtils;

import java.util.List;

public class MyAdapter extends BaseQuickAdapter<MyOrderInfoBean.OrdermapBean.ProdcutListBean, BaseViewHolder> {

    public MyAdapter(@Nullable List<MyOrderInfoBean.OrdermapBean.ProdcutListBean> data) {
        super(R.layout.view_item_shopping_cart_order, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyOrderInfoBean.OrdermapBean.ProdcutListBean item) {
        ImageView ivIcon = helper.getView(R.id.iv_icon);
        String img_zt = "";
        if (!TextUtils.isEmpty(item.getImg_zt())) {
            final String[] splitImgZt = item.getImg_zt().split(",");
            if (splitImgZt.length > 0) {
                img_zt = splitImgZt[0];
            }
        }
        if (!img_zt.equals(ivIcon.getTag())) {
            ivIcon.setTag(img_zt);
            GlideUtils.loadImg(mContext, ivIcon, img_zt, R.mipmap.default_foods_icon);
        }
//        if (!TextUtils.isEmpty(item.getImg_zt())) {
//            final String[] imgArr = item.getImg_zt().split(",");
//            Glide.with(mContext).load(imgArr[0]).into(ivIcon);
//        } else {
//            GlideUtils.loadImg(mContext, ivIcon, R.mipmap.logo);
//        }
    }
}